/**
 * 上传接口
 * @param {*} app 
 */

module.exports = app => {
  const multer = require('multer');
  const config = require('../../config');

  const upload = multer({
    dest: __dirname + '/../../uploads' // 上传路径
  })
  app.post('/admin/api/upload', upload.single('file'), async (req, res) => {
    const file = req.file;
    // 返回url地址
    file.url = `${config.uploadUrl}${file.filename}`
    console.log(file)
    res.send(file)
  })
}